home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / SAMPLES.BIN / FindDialog.java < prev    next >
Encoding:
Java Source  |  1996-12-08  |  2.6 KB  |  97 lines

  1. /*
  2.     A basic extension of the java.awt.Dialog class
  3.  */
  4.  
  5. import java.awt.*;
  6.  
  7. public class FindDialog extends Dialog {
  8.     void cancelButton_Clicked(Event event) {
  9.         // to do: place event handler code here.
  10.         hide();
  11.         dispose();
  12.     }
  13.  
  14.     void findButton_Clicked(Event event) {
  15.         // to do: place event handler code here.
  16.         hide();
  17.         dispose();
  18.     }
  19.  
  20.     public boolean matchCase()
  21.     {
  22.         return m_MatchCase.getState();
  23.     }
  24.     public String getFindString()
  25.     {
  26.         return findText.getText();
  27.     }
  28.  
  29.     public FindDialog(Frame parent, boolean modal) {
  30.  
  31.         super(parent, modal);
  32.  
  33.         //{{INIT_CONTROLS
  34.         setLayout(null);
  35.         addNotify();
  36.         resize(insets().left + insets().right + 358,insets().top + insets().bottom + 98);
  37.         setBackground(new Color(12632256));
  38.         findText = new java.awt.TextField();
  39.         findText.reshape(insets().left + 80,insets().top + 20,190,20);
  40.         add(findText);
  41.         findButton = new java.awt.Button("Find");
  42.         findButton.reshape(insets().left + 280,insets().top + 10,70,20);
  43.         add(findButton);
  44.         cancelButton = new java.awt.Button("Cancel");
  45.         cancelButton.reshape(insets().left + 280,insets().top + 40,70,20);
  46.         cancelButton.setFont(new Font("Dialog", Font.BOLD, 10));
  47.         add(cancelButton);
  48.         label2 = new java.awt.Label("Find What");
  49.         label2.reshape(insets().left + 0,insets().top + 10,80,16);
  50.         add(label2);
  51.         m_MatchCase = new java.awt.Checkbox("Match case");
  52.         m_MatchCase.reshape(insets().left + 10,insets().top + 60,100,20);
  53.         m_MatchCase.setBackground(new Color(12632256));
  54.         add(m_MatchCase);
  55.         setTitle("Dialog1");
  56.         //}}
  57.     }
  58.  
  59.     public FindDialog(JavaPad parent, String title, boolean modal, String findString) {
  60.         this(parent, modal);
  61.         setTitle(title);
  62.         findText.setText(findString);
  63.     }
  64.  
  65.     public synchronized void show() {
  66.         Rectangle bounds = getParent().bounds();
  67.         Rectangle abounds = bounds();
  68.  
  69.         move(bounds.x + (bounds.width - abounds.width)/ 2,
  70.              bounds.y + (bounds.height - abounds.height)/2);
  71.  
  72.         super.show();
  73.     }
  74.  
  75.     public boolean handleEvent(Event event) {
  76.         if(event.id == Event.WINDOW_DESTROY) {
  77.             hide();
  78.             return true;
  79.         }
  80.         if (event.target == findButton && event.id == Event.ACTION_EVENT) {
  81.             findButton_Clicked(event);
  82.         }
  83.         if (event.target == cancelButton && event.id == Event.ACTION_EVENT) {
  84.             cancelButton_Clicked(event);
  85.         }
  86.         return super.handleEvent(event);
  87.     }
  88.  
  89.     //{{DECLARE_CONTROLS
  90.     java.awt.TextField findText;
  91.     java.awt.Button findButton;
  92.     java.awt.Button cancelButton;
  93.     java.awt.Label label2;
  94.     java.awt.Checkbox m_MatchCase;
  95.     //}}
  96. }
  97.